<link type="text/css" href="<?=Yii::app()->params["urlRs"] ?>/js/jqueryui/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Yii::app()->params["urlRs"] ?>/js/jqueryui/jquery-ui-1.8.23.custom.min.js"></script>
<script type="">

    //-----------------------------------------------------------------------------------------------------------------//   

    var filename = "";
    var filepath = "";
    function getdata(data_json){              
        var json = $.parseJSON(data_json);
        var code = json.code;   

        if(code == '105')
            {
            filename = json.data["filename"];            
            //filetype = json.data["filetype"];
            //filesize = json.data["filesize"];
            filepath = "/" + json.data["forder_up"]  + "/" + ""+filename;
            path = "<?=Yii::app()->params['urlImage']?>/"+ json.data["forder_up"]  + "/" + ""+filename;            
            //path = "http://images.az24.vn"+ json.data["path"]  + "/" + ""+filename;            
            $("#txtFileName").val(filepath);
            $("#thumbnails").html("<img style='max-height: 200px;max-width: 200px;' src='"+path+"'/>");                          
        }
        else
            {
            var msg = json.msg;                
            alert(msg);    
        }
    }

    //-----------------------------------------------------------------------------------------------------------------//

    var swfu;
    window.onload = function () {
        swfu = new SWFUpload({
            // Backend Settings
            upload_url: "<?=$link_url ?>",
            post_params: "resume_file",

            // File Upload Settings
            file_size_limit : "4 MB",
            file_types : "*.*",
            file_types_description : "Tài liệu",
            file_upload_limit : "0",

            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,
            upload_progress_handler : uploadProgress,
            upload_error_handler : uploadError,
            upload_success_handler : uploadSuccess,
            upload_complete_handler : uploadComplete,

            // Button Settings
            button_image_url : "<?php echo Yii::app()->params['urlRs']; ?>/js/swfupload/XPButtonUploadText_61x22.png",
            button_placeholder_id : "spanButtonPlaceholder",
            button_width: 61,
            button_height: 22,

            // Flash Settings
            flash_url : "<?php echo Yii::app()->params['urlRs']; ?>/js/swfupload/swfupload.swf",

            custom_settings : {
                upload_target : "divFileProgressContainer"
            },

            // Debug Settings
            //debug: true
        });
    };

    //-----------------------------------------------------------------------------------------------------------------//

    $(function() {
        $('#project_start_date,#project_end_date').datepicker({
            changeYear: true,
            dateFormat:'dd/mm/yy',                                    
            showOn:'both',           
            buttonImage: '<?=Yii::app()->params["urlRs"]."/images/calendar.png"?>',
            buttonImageOnly: 'true'
        });   

        $(".ui-datepicker-trigger").css("margin-bottom","-5px");
        $(".ui-datepicker-trigger").css("margin-left","5px"); 
    });

    function edit_project(project_id){
        var project_public = 1;

        var project_name = $('#project_name').val();       
        var project_description = $('#project_description').val();               
        var project_homepage = $('#project_homepage').val();           
        var project_budget = $('#project_budget').val();           
        var project_company = $('#project_company').val();           
        var project_customer = $('#project_customer').val();           
        var project_start_date = $('#project_start_date').val();           
        var project_end_date = $('#project_end_date').val();           
        var project_image = $('#txtFileName').val();           
        var project_is_public = $('#project_is_public').is(':checked');     
        if(project_is_public == false){
            project_public = 0;
        }

        var flag_err = 0;
        var err_msg = '';
        $('#errorExplanation').slideUp('slow');
        $('#err_msg').empty();
        if(project_name == ''){
            flag_err = 1;
            err_msg = '<li>Chưa điền tên tài dự án!</li>'
            $('#err_msg').append(err_msg);
        }
        if(project_description == ''){
            flag_err = 1;
            err_msg = '<li>Chưa điền mô tả dự án!</li>'
            $('#err_msg').append(err_msg);
        }        
        if(flag_err == 1){
            $('#errorExplanation').slideDown('slow');
            return false;    
        }else{            
            $('#errorExplanation').slideUp('slow');
            var strUrl = '<?=$url->createUrl("project/ajaxUpdateProject") ?>';            
            loadingAjax();
            $.ajax({
                type: "GET",
                url: strUrl,
                data: {project_company:project_company,project_customer:project_customer,project_name:project_name,project_description:project_description,project_id:project_id,project_homepage:project_homepage,project_public:project_public,project_budget:project_budget,project_start_date:project_start_date,project_end_date:project_end_date,project_image:project_image},
                success: function(msg){                            
                    if(msg==1){                       
                        $('#errorExplanation').slideUp('slow');
                        $('#flash_notice').slideDown('slow');
                    }
                    $("#submit_button").removeAttr("disabled");

                },
                beforeSend:function(){
                    $("#submit_button").attr("disabled","disabled");                
                }
            });
        }  
        closeLoadingAjax();
    }

</script>